package com.learn.apis;

import com.learn.entities.PayDTO;
import com.learn.resp.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author DJJ_F
 * @version 1.0
 * @date 2025/07/31
 * @description ch06 openfeign
 * ch07 断路器
 * ch08 网关
 */
//@FeignClient(value = "cloud-payment-service")
// 如果写成上面那样，无论网关开没开都能访问，需要写成下面的样子，才会先找网关再找服务
@FeignClient(value = "cloud-gateway")
public interface PayFeignApi {
    @PostMapping("/pay/add")
    Result addPay(@RequestBody PayDTO payDTO);

    @DeleteMapping("/pay/del/{id}")
    Result deletePayById(@PathVariable("id") Integer id);

    @PutMapping("/pay/update")
    Result updatePayById(@RequestBody PayDTO payDTO);

    @GetMapping("/pay/get/{id}")
    Result selectOneById(@PathVariable("id") Integer id);

    @GetMapping("/pay/get")
    Result selectAll();

    @GetMapping("/pay/info")
    String getInfo();

    /**
     * 很多章节的测试都用这个接口
     * @param id
     * @return
     */
    @GetMapping("/pay/circuit/{id}")
    String circuit(@PathVariable("id") Integer id);

    @GetMapping("/pay/gateway/get/{id}")
    Result getById(@PathVariable("id") Integer id);

    @GetMapping(value = "/pay/gateway/info")
    Result getGatewayInfo();

    @GetMapping(value = "/pay/gateway/filter")
    Result getGatewayFilter();
}
